package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentReplyService;
import com.heima.comment.service.CommentService;
import com.heima.model.comment.dtos.CommentDto;
import com.heima.model.comment.dtos.CommentLikeDto;
import com.heima.model.comment.dtos.CommentSaveDto;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comment")
@Slf4j
public class CommentController {
    @Autowired
    private CommentService commentService;
    @PostMapping("/save")
    public ResponseResult saveComment(@RequestBody CommentSaveDto dto) {
        log.info("新增评论的参数{}", dto);
        return commentService.saveComment(dto);
    }

    @PostMapping("/load")
    public ResponseResult queryCommentList(@RequestBody CommentDto dto) {
        log.info("查询评论列表参数{}", dto);
        return commentService.queryList(dto);
    }
    @ApiOperation("点赞评论")
    @PostMapping("/like")
    public ResponseResult addOrDeleteReply(@RequestBody CommentLikeDto dto){
        return commentService.addOrDeleteReply(dto);
    }

}
